.L, Start,, implement later ability to restart
nop
,,,
,,, Global Values Do not change
,,, %s0 = balls direction
,,,
movi, $0, %s0, right

,,,
,,, Intialize Game Setup Values/registers
,,, Can extract to use to test hardware
,,,
movi, $32, %ballx
movi, $50, %bally
movi, $0, %p1_paddle
movi, $126, %p2_paddle
movi, $0, %p1_score
movi, $0, %p2_score
movi, $0, %p1_input
movi, $0, %p2_input

.L, BeginGame,, REPEATING FUNCTIONS BELOW: No variable preintializations that are not dynamicly set

,,,
,,, s0 - direction
,,, s1 - rightside screen boundaries = 72<<3 = 608
,,, s2 - bottom of screen boundaries = 120<<2
,,, s3 - score width from edge of screen?
,,, s4 - balls speed

movi, $72, %s1
lshi, $-3, %s1
movi, $112, %s2
lshi, $-2, %s2
movi, $1, %s4

,,,
,,, Collision Detection for ball
,,,
.L, Collision,,
cmpi, $32, %ballx, ball hit player one
jei, &player1

cmp, %s1, %ballx, ball hit player two
jei, &player2

cmpi, $0, %bally, ball hit celling
jei, &Wall

cmp, %s2, %bally, ball hit floor
jei, &Wall
j, &end

.L, Wall
,,,xori, $4, %s0, flip direction down/up
movi, $1, %s0
j, &end

.L, player2,, set movement left
movi, $1, %s0, change direct to left
j, &end

.L, player1,, set movement right
movi, $0, %s0, change direct to right

.L, end

,,, %s0
,,, 0 Right
,,, 1 Left
,,, 2 Right Up
,,, 3 Left Up
,,, 6 Right Down (keep low bits the same as the right up)
,,, 7 Left Down
,,,

.L, direction
cmpi, $0, %S0, right
jei, &right

cmpi, $1, %s0, left
jei, &left

cmpi, $2, %s0, right up
jei, &rightUP

cmpi, $3, %s0, left up
jei, &leftUP

cmpi, $6, %s0, right down
jei, &rightDOWN

cmpi, $7, %s0, left down
jei, &leftDOWN
,,,Reach here error fix it...
movi, $0, %s0
j, &endBall

.L, left
sub, %s4, %ballx, straight left
j, &endBall

.L, right
add, %s4, %ballx, straight right
j, &endBall

.L, rightDOWN
add, %s4, %ballx, down and to the right
add, %s4, %bally
j, &endBall

.L, leftUP
sub, %s4, %ballx, up and to the left
sub, %s4, %bally
j, &endBall

.L, leftDOWN
sub, %s4, %ballx, down and to the left
add, %s4, %bally
j, &endBall

.L, rightUP
add, %s4, %ballx, up and to the right
sub, %s4, %bally


.L, endBall

,,,
,,, End Ball()
,,,

,,,
,,, Prevent game from going to fast, Refresh Rate Loop = 500
,,, s5 will equal 32766.... this will cause it to wait about 5 ms ish
,,,wait, $100

movi, $127, %s5
lshi, $-7, %s5
addi, $127, %s5
lshi, $-1, %s5

.L, wait
nop
nop
subi, $1, %s5
cmpi, $0, %s5
jei, &wait2Begin
j, &wait
,,,2x

.L, wait2Begin
movi, $127, %s5
lshi, $-3, %s5

.L, wait2
nop
nop
subi, $1, %s5
cmpi, $0, %s5
jei, &BeginGame
j, &wait2,, REPEAT MOVEMENT...